//
//  UILabelViewController.m
//  UITest
//
//  Created by wp w on 12-6-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "UILabelViewController.h"

@interface UILabelViewController ()

@end

@implementation UILabelViewController
@synthesize label1;
@synthesize label2;


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    //直接使用代码创建label
    CGRect labelFrame = CGRectMake(10,10,200,44);
	UILabel *myLabel = [[UILabel alloc] initWithFrame:labelFrame];
	
	myLabel.backgroundColor = [UIColor clearColor];
	myLabel.textColor = [UIColor redColor];
	myLabel.font = [UIFont fontWithName:@"Verdana" size:18.0];
	
	myLabel.numberOfLines = 2;
	myLabel.text = @"Hello World\nSecond line";
	
	myLabel.shadowColor = [UIColor darkGrayColor];
	myLabel.shadowOffset = CGSizeMake(1.0,1.0);
	
	[self.view addSubview:myLabel];
	
	[myLabel release];	
    
    //设置资源中的label
    label1.adjustsFontSizeToFitWidth = YES;
    label1.backgroundColor = [UIColor blueColor];
    
    label2.adjustsFontSizeToFitWidth = NO;
    label2.backgroundColor = [UIColor greenColor];
    
    //文字太宽时处理方式
//    label1.lineBreakMode ＝ UILineBreakModeWordWrap;    
//    typedef enum {
//        UILineBreakModeWordWrap = 0,
//        UILineBreakModeCharacterWrap,
//        UILineBreakModeClip,
//        UILineBreakModeHeadTruncation,
//        UILineBreakModeTailTruncation,
//        UILineBreakModeMiddleTruncation,
//    } UILineBreakMode;
}

- (void)viewDidUnload
{
    [self setLabel1:nil];
    [self setLabel2:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
    [label1 release];
    [label2 release];
    [super dealloc];
}
- (IBAction)l1Click {
    [label1 setFrame:CGRectInset(label1.frame, -4, -2)];
}

- (IBAction)l1_Click {
     [label1 setFrame:CGRectInset(label1.frame, 4, 2)];
}

- (IBAction)l2Click {
    [label2 setFrame:CGRectInset(label2.frame, -4, -2)];
}



@end
